.PHONY : rebuild

CC = mips-linux-gnu-g++
TARGET = cpp_hello.out


src += $(wildcard ./*.cpp)


src += $(wildcard ./utils/auto_init/*.cpp)
INCLUDE += -I./include/utils/auto_init/


src += $(wildcard ./dev_drv/inputdev/drv_manager/inputdrv/*.cpp)
INCLUDE += -I./include/dev_drv/inputdev/drv_manager/inputdrv/


src += $(wildcard ./dev_drv/inputdev/drv_manager/*.cpp)
INCLUDE += -I./include/dev_drv/inputdev/drv_manager/


src += $(wildcard ./dev_drv/dev_manager/*.cpp)
INCLUDE += -I./include/dev_drv/dev_manager/


src += $(wildcard ./dev_drv/dev_func/*.cpp)  
INCLUDE += -I./include/dev_drv/dev_func/


src += $(wildcard ./lock_manager/*.cpp)
INCLUDE += -I./include/lock_manager/


src += $(wildcard ./dev_drv/inputdev/*.cpp)
INCLUDE += -I./include/dev_drv/inputdev/


src += $(wildcard ./utils/event_waiter_frame/*.cpp)
INCLUDE += -I./include/utils/event_waiter_frame/


src += $(wildcard ./utils/*.cpp)
INCLUDE += -I./include/utils/


INCLUDE += -I./include/
INCLUDE += -I../boost_lib/include


#mylogger
INCLUDE += -I./mylogger/demo/easylogger/inc  -I./mylogger/demo/easylogger/plugins/ 
INCLUDE += -I./mylogger/easylogger/plugins/ -I./mylogger/easylogger/inc


src +=  $(wildcard ./mylogger/easylogger/src/*.cpp)
src +=  $(wildcard ./mylogger/easylogger/plugins/file/elog_file.cpp)
src +=  $(wildcard ./mylogger/demo/easylogger/port/*.cpp)
src +=  $(wildcard ./mylogger/demo/easylogger/plugins/file/*.cpp)


INCLUDE += -I./EFSM/ -I./include/EFSM/ 
src +=	$(wildcard ./EFSM/*.cpp)

# 下面的是没有头文件或者在INCLUDE文件夹内没有对应头文件的 源文件 
src += $(wildcard ./boost_mine_config/*.cpp)



ADDLIB_l += -lboost_thread -lboost_system  -lstdc++ -lrt -lpthread -lm
ADDLIB_L += -L../boost_lib/libs/boost/ 

OBJS := $(patsubst %.cpp,%.o,$(src))

$(TARGET) : $(OBJS)
	$(CC) $(ADDLIB_L) $(ADDLIB_l) -Tmylink.lds $^ -o  $@
	@echo "****  [link over]  *****\n"

$(OBJS) : %.o : %.cpp
	@echo "\n"
	$(CC)  $(INCLUDE)  -o $@ -c -g $^
	@echo "****  [compile over]  ****\n"

clean: 
	$(RM) $(OBJS)
	$(RM) $(TARGET)
	@echo "****  [clean over]  *****\n"

rebuild: clean $(TARGET)



# 很多makefile，如果只修改头文件的内容，再去编译，即使理论上已经不存在编译错误了，
# 但是执行make，依然会编译报错。  这都是makefile功力不够的体现。
# 本工程makefile应该也存在类似问题

#同时， 本工程的makefile没有做到头文件能够自动依赖，
#这些都是需要后续增强的。 


